package com.hns.can.mainte.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.hns.can.common.service.BaseInfoValueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hns.can.common.aop.orgTree.LeftOrgAnnotation;
import com.hns.can.common.constants.GlobalConst;
import com.hns.can.common.formula.FillCodeDscValue;
import com.hns.can.common.formula.FillParamsVo;
import com.hns.can.common.vo.CommonParamsVo;
import com.hns.can.mainte.vo.BatteryStatusVo;
import com.hns.frame.mybatis.Pagination;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;

/**
 * 电池状态Service
 * @author:zhangzq
 * @email:
 * @version Revision 2.0.0
 */
@Service
public class BatteryStatusService extends CommonService {

    @Autowired
    private BaseInfoValueService baseInfoValueService;

    /**
     * 分页查询电池状态̬
     * @param params
     * @return
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @SuppressWarnings("unchecked")
	@LeftOrgAnnotation()
    @Transactional
    public Pagination searchBatteryStatus(CommonParamsVo params) throws Exception {
        Pagination page = this.myBatisPage("batteryStatus.searchBatteryStatusCount", "batteryStatus.searchBatteryStatusInfo", params, BatteryStatusVo.class);
        List list = page.getData();
        baseInfoValueService.fillOrganLineLicPltNoBatteryType(list);
        page.setData(list);
        return page;
    }

    /**
     * 查询电池状态用于导出״̬
     * @param params
     * @return
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @SuppressWarnings("unchecked")
    @LeftOrgAnnotation()
    @Transactional
    public List<BatteryStatusVo> getBatteryStatusData(CommonParamsVo params) throws Exception {
        List list = PubUtil.convertListMapToObject(sqlMapDao.selectList("batteryStatus.searchBatteryStatusInfo", params), BatteryStatusVo.class);
        baseInfoValueService.fillOrganLineLicPltNoBatteryType(list);
        return list;
    }

    /**
     * 查询soc数据
     * @param params
     * @return
     * @author:zhangzq
     * @email:
     */
    @SuppressWarnings("unchecked")
    public List<BatteryStatusVo> socCharts(CommonParamsVo params) {
        List<BatteryStatusVo> list = PubUtil.convertListMapToObject(sqlMapDao.selectList("batteryStatus.getSocChartsData", params), BatteryStatusVo.class);
        return list;
    }

    /**
     * 查询电池电压数据
     * @param params
     * @return
     * @author:zhangzq
     * @email:
     */
    @SuppressWarnings("unchecked")
    public List<BatteryStatusVo> voltageAnalysis(CommonParamsVo params) {
        List<BatteryStatusVo> list = PubUtil.convertListMapToObject(sqlMapDao.selectList("batteryStatus.getVoltageChartsData", params), BatteryStatusVo.class);
        return list;
    }
}

